﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using u = FinPlusUtility.Utility;
using log = Logger.Logger;

namespace FinPlusCommon
{
    [ServiceContract(SessionMode = SessionMode.Allowed, CallbackContract = typeof(IFunctionCallback))]
    public interface IFunctionService
    {
        [OperationContract]
        [FaultContract(typeof(Exception))]
        void GetFunctions(u.Env env, string user, string config, string serviceKey, string serviceType, string parms, string guid);

        [OperationContract]
        [FaultContract(typeof(Exception))]
        void SaveFunction(u.Env env, string user, string config, string serviceKey, IEnumerable<Item> function, ChangeType changeType, string guid);

        [OperationContract]
        [FaultContract(typeof(Exception))]
        void AlterFunction(u.Env env, string user, string config, string serviceKey, DateTime timeStamp, string functionName, int id, string itemName, object value);

        [OperationContract]
        void Dispose(u.Env env, string user, string config, string serviceKey, string guid);
    }

    [ServiceContract]
    public interface IFunctionCallback
    {
        [OperationContract(IsOneWay = false)]
        [FaultContract(typeof(Exception))]
        void DispatchFunction(u.Env env, string serviceKey, string guid, IEnumerable<Item> function, ChangeType changeType);

        [OperationContract(IsOneWay = false)]
        [FaultContract(typeof(Exception))]
        void DispatchItem(u.Env env, string serviceKey, string guid, int functionId, Item item, ChangeType changeType);

        [OperationContract(IsOneWay = false)]
        [FaultContract(typeof(Exception))]
        void DispatchCompleted(u.Env env, string serviceKey, string guid);
    }
}
